home *** CD-ROM | disk | FTP | other *** search
-
- A-1
-
- Appendix A: Differences Between CHASM and That Other Assembler
-
- Virtually all magazine articles about assembly language
- programming on the IBM PC assume that the reader is using That
- Other Assembler - you know, the one that costs $100. This
- appendix will try to summarize the differences between the two
- programs. Please note that I do not own a copy of That Other
- Assembler, and therefore this section is not complete, nor even
- guaranteed to be correct. Anyone with more experience is
- invited to make additions or corrections.
-
- A. General Differences
-
- The biggest difference is philosophical. The IBM assembler was
- designed for use by professional assembly language programmers,
- to write operating systems and other huge projects. This is
- reflected in the large size and relative complexity of the macro
- assembler.
-
- On the other hand, CHASM was designed for use by beginners, to
- write relatively short programs. This was done by leaving out a
- lot of the power offered by IBM's assembler, in exchange for
- simplicity and small size. The main simplification involved
- producing object code in the COM format, rather than the EXE
- format chosen by IBM. There are two main consequences of this
- choice:
-
- 1. You can't link routines assembled by CHASM to
- compiled programs. (Although you *can* include them in
- BASIC programs, interpreted or compiled.)
-
- 2. Your program has to fit in one 64K segment. If (shudder!)
- you want to write a 256K assembly language program, you're
- out of luck.
-
- Like Pascal, the IBM assembler is a strongly typed language. By
- requiring you to specify the *type* of each memory location you
- will access in your program, the IBM assembler always knows what
- size of memory operand you want. The disadvantage is a loss of
- freedom: if you want to access only one byte of an area declared
- as word, that's tough.
-
- In analogy to the C language, CHASM is *not* strongly typed.
- CHASM is perfectly happy extracting a byte from where you
- originally set aside a word - CHASM can't tell the difference.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- A-2
-
- The consequence of this is that you have to *tell* CHASM
- explicitly whether you want a byte or a word every time you
- access memory. For any access to memory which doesn't have a
- register as the other operand, you must add either a 'B' or a 'W'
- to the instruction mnemonic used by IBM.
-
- B. Miscellaneous Differences:
-
- 1. Short Jumps:
-
- IBM uses the SHORT keyword, CHASM uses an 'S' suffix.
- Example:
-
- JMP SHORT label ;ibm
- JMPS label ;chasm
-
- 2. Offset Function:
-
- Where IBM precedes an operand with the keyword OFFSET,
- CHASM has a *function* called OFFSET. CHASM requires
- parentheses around the operand. Example:
-
- MOV AX, OFFSET FCB ;ibm
- MOV AX, OFFSET(FCB) ;chasm
-
- 3. Declaring Storage:
-
- A. If you don't care what value a memory location is
- initialized to, the IBM assembler allows you to specify
- '?' as its contents. CHASM figures out how many bytes
- you are declaring by how many values you give, so you
- have to specify a starting value for every memory
- location you declare. Example:
-
- DB ? ;ibm
- DB 0 ;chasm
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- A-3
-
- B. The IBM assembler has a dizzying array of storage
- defining pseudo-ops, in keeping with its strongly typed
- philosophy. In practice, the only ones you'll likely
- see are DB (declare byte) and DW (declare word). Where
- you see DB in IBM syntax, declare a single byte in
- CHASM. For DW, declare two bytes. Example:
-
- DW ? ;ibm
- DB 00H, 00H ;chasm
-
- C. The IBM assembler allows the keyword DUP as an operand
- in storage declaring pseudo-ops. This means to repeat
- the definition as many times as the number just before
- the DUP. Example:
-
- DW 3 DUP(?) ;ibm
- DB 0, 0 ;chasm
- DB 0, 0 ; "
- DB 0, 0 ; "
-
- 4. Expressions:
-
- The IBM assembler allows you to perform arithmetic within the
- operand list to calculate an address or immediate operand.
- Thus, if you wanted the offset of the third byte after a
- label, you could use "label + 3" as an operand. CHASM doesn't
- support expression evaluation. The solution is to add labels
- to any locations accessed via an expression, then use the
- label directly. Example:
-
- MOV AX, BUFFER + 3 ;ibm
- BUFFER DB 4 DUP(?) ; "
-
- MOV AX, BUFFER3 ;chasm
- BUFFER DB 0, 0, 0 ; "
- BUFFER3 DB 0 ; "
-
- Sometimes a constant is given as an expression just to
- emphasize its origin. For any such expressions which do not
- involve a label, just substitute the numerical value of the
- expression.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- A-4
-
- 5. Segment Overrides:
-
- The IBM assembler specifies a segment override as a prefix
- attached to a memory operand. CHASM uses a separate
- instruction, SEG, to override the default segment register for
- the following instruction. Example:
-
- XOR AL, ES:[DI] ;ibm
-
- SEG ES ;chasm
- XOR AL, [DI] ; "
-
- 6. ASSUME Pseudo-op:
-
- IBM's ASSUME pseudo-op tells the assembler where the segment
- registers will be pointing. CHASM always assumes that the CS,
- DS and SS registers point to the beginning of the code
- segment, and that the SS register has been set up to point to
- a valid stack area. If you find an ASSUME pseudo-op where the
- CS, DS and ES registers point to different locations, you will
- have to figure out the addresses for memory references in the
- DS or ES segments yourself.
-
-
- 7. Segment Pseudo-op:
-
- This pseudo-op is used to set up multiple segments in the IBM
- assembler. Since CHASM only allows one segment, there is no
- equivalent pseudo-op. If there is only one segment definition
- in an IBM assembler program, everything is fine, just leave
- the pseudo-op out for CHASM.
-
- Often times the SEGMENT pseudo-op is used to provide
- addressing of an area in the BIOS, or perhaps the interrupt
- vector table at the beginning of memory. For example, if a
- program needed to get at the BIOS data area, in the IBM
- assembler you would define a dummy segment with the same
- structure as that in the BIOS listing in Technical Reference:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- A-5
-
- DATA SEGMENT AT 40H
- RS232_BASE DW 4 DUP(?)
- PRINTER_BASE DW 4 DUP(?)
- EQUIP_FLAG DW ?
- MFG_TST DB ?
- MEMORY_SIZE DW ?
- IO_RAM_SIZE DW ?
-
- All this is really accomplishing is giving a name to some
- memory locations which are outside the actual program being
- written.
-
- For CHASM, you'll have to figure out the actual addresses of
- any of these data areas you want to use. In this case, you
- can just look at the LOC column of the BIOS listing to get the
- offset of each data area. For example, EQUIP_FLAG is at
- offset 10H (check page A-2 of Tech. Ref). Given the
- addresses, you can give CHASM names for each of the locations,
- using the memory option of the EQU pseudo-op:
-
- RS232_BASE EQU [00H]
- PRINTER_BASE EQU [08H]
- EQUIP_FLAG EQU [10H]
- MFG_TEST EQU [12H]
- MEMORY_SIZE EQU [13H]
- IO_RAM_SIZE EQU [15H]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-